﻿<core:ViewBase  x:Class="DXTools.UI.Modules.MetadataBrowser.Views.EntityView"
    xmlns:core="clr-namespace:DXTools.UI.Core.View;assembly=DXTools.UI.Core"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:layout="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
    xmlns:metadata="clr-namespace:DXTools.UI.Modules.MetadataBrowser" 
    xmlns:converters="clr-namespace:DXTools.UI.Core.Converters;assembly=DXTools.UI.Core"
    xmlns:MBConverters="clr-namespace:DXTools.UI.Modules.MetadataBrowser.Converters"            
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="800" Margin="5,5,15,5">
    
    <UserControl.Resources>
        <MBConverters:ObjectConverter x:Key="ConvertObject" />
    </UserControl.Resources>
    <toolkit:BusyIndicator IsBusy="{Binding IsBusy}">


        <Grid x:Name="LayoutRoot" >

        <Grid.RowDefinitions>
            <RowDefinition Height="33" ></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Background="DarkGray" VerticalAlignment="Stretch">
                <Border CornerRadius="5" Margin="2,3,1,2" Background="White" HorizontalAlignment="Left" BorderBrush="#C0CDDC" BorderThickness="0">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="200"/>
                            <ColumnDefinition Width="24" />
                           
                        </Grid.ColumnDefinitions>

                        <TextBox Grid.Column="0" Margin="0"  Text="{Binding Path=SearchText, Mode=TwoWay}" 
                                 metadata:EnterKeyDown.Command="{Binding SearchCommand}" 
                                 metadata:EnterKeyDown.CommandArgument="{Binding Path=Text,RelativeSource={RelativeSource Self}}"
                                 BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Center" Name="uxSearchText"  Width="200" Height="20"/>
                        <Button  Grid.Column="1"  Margin="0"                    
                        Command="{Binding SearchCommand}" BorderThickness="0" ToolTipService.ToolTip="Search" >
                            <Button.Content>
                                <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Center" >
                                    <Image Source="../Images/search.png"   Width="21" Height="20" />
                                </StackPanel>
                            </Button.Content>
                        </Button>
                    </Grid>
                </Border>
            </StackPanel>
        <!-- Create a simple TabControl in XAML. -->
        <sdk:TabControl x:Name="uxTab" Grid.Row="1" >
            <sdk:TabItem Header="Attributes">
                <Grid HorizontalAlignment="Stretch">
                        <data:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding FilteredAttributeList}"  HorizontalAlignment="Stretch"  Name="uxData" IsReadOnly="True"  >
                        <!--<data:DataGrid.ColumnHeaderStyle>
                            <Style TargetType="primitives:DataGridColumnHeader" >
                                <Setter Property="FontSize" Value="12" />
                                <Setter Property="FontWeight" Value="Bold"  />
                                <Setter Property="Margin" Value="0" />
                                <Setter Property="Padding" Value="2" />
                                <Setter Property="VerticalContentAlignment" Value="Bottom" />
                                <Setter Property="Height" Value="140" />
                                <Setter Property="ContentTemplate" >
                                    <Setter.Value>
                                        <DataTemplate >
                                            <layout:LayoutTransformer>
                                                <layout:LayoutTransformer.LayoutTransform>
                                                    <RotateTransform Angle="-35"/>
                                                </layout:LayoutTransformer.LayoutTransform>
                                                <TextBlock Text="{Binding}" TextWrapping="Wrap"   />
                                            </layout:LayoutTransformer>
                                        </DataTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </data:DataGrid.ColumnHeaderStyle>-->

                        <data:DataGrid.Columns>
                            <data:DataGridTextColumn Header="Logical Name" Binding="{Binding LogicalName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Schema Name" Binding="{Binding SchemaName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Display Name" Binding="{Binding DisplayName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Attribute Type" Binding="{Binding AttributeType, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Description" Binding="{Binding Description, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Required Level" Binding="{Binding RequiredLevel, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Audit Enabled" Binding="{Binding IsAuditEnabled, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Custom Attribute" Binding="{Binding IsCustomAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Customizable" Binding="{Binding IsCustomizable, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Managed" Binding="{Binding IsManaged, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is PrimaryId" Binding="{Binding IsPrimaryId, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Primary Name" Binding="{Binding IsPrimaryName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Renameable" Binding="{Binding IsRenameable, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Secured" Binding="{Binding IsSecured, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Advanced Find" Binding="{Binding IsValidForAdvancedFind, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Create" Binding="{Binding IsValidForCreate, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Read" Binding="{Binding IsValidForRead, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Update" Binding="{Binding IsValidForUpdate, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Can Be Secured For Create" Binding="{Binding CanBeSecuredForCreate, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Can Be Secured For Read" Binding="{Binding CanBeSecuredForRead, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Can Be Secured For Update" Binding="{Binding CanBeSecuredForUpdate, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Can Modify Additional Settings" Binding="{Binding CanModifyAdditionalSettings, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Attribute Of" Binding="{Binding AttributeOf, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity Logical Name" Binding="{Binding EntityLogicalName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Column Number" Binding="{Binding ColumnNumber, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Linked Attribute Id" Binding="{Binding LinkedAttributeId, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Deprecated Version" Binding="{Binding DeprecatedVersion, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Metadata Id" Binding="{Binding MetadataId, Converter={StaticResource ConvertObject}}" />
                        </data:DataGrid.Columns>
                    </data:DataGrid>
                </Grid>
            </sdk:TabItem>

            <sdk:TabItem Header="N:1 Relationships">
                <Grid HorizontalAlignment="Stretch" >
                        <data:DataGrid Grid.Row="1" AutoGenerateColumns="False" ItemsSource="{Binding FilteredRelationshipsN1List}"  HorizontalAlignment="Stretch"  Name="uxManyToOne" IsReadOnly="True" >
                        <!--<data:DataGrid.ColumnHeaderStyle>
                            <Style TargetType="primitives:DataGridColumnHeader" >
                                <Setter Property="FontSize" Value="12" />
                                <Setter Property="FontWeight" Value="Bold"  />
                                <Setter Property="Margin" Value="0" />
                                <Setter Property="Padding" Value="2" />
                                <Setter Property="VerticalContentAlignment" Value="Bottom" />
                                <Setter Property="Height" Value="140" />
                                <Setter Property="ContentTemplate" >
                                    <Setter.Value>
                                        <DataTemplate >
                                            <layout:LayoutTransformer>
                                                <layout:LayoutTransformer.LayoutTransform>
                                                    <RotateTransform Angle="-35"/>
                                                </layout:LayoutTransformer.LayoutTransform>
                                                <TextBlock Text="{Binding}" TextWrapping="Wrap"   />
                                            </layout:LayoutTransformer>
                                        </DataTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </data:DataGrid.ColumnHeaderStyle>-->
                        <data:DataGrid.Columns>
                            <data:DataGridTextColumn Header="Schema Name" Binding="{Binding SchemaName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referencing Entity" Binding="{Binding ReferencingEntity, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referenced Entity" Binding="{Binding ReferencedEntity, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referencing Attribute" Binding="{Binding ReferencingAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referenced Attribute" Binding="{Binding ReferencedAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Associated Menu Configuration" Binding="{Binding AssociatedMenuConfiguration, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Cascade Configuration" Binding="{Binding CascadeConfiguration, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Custom Relationship" Binding="{Binding IsCustomRelationship, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Customizable" Binding="{Binding IsCustomizable, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Managed" Binding="{Binding IsManaged, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Advanced Find" Binding="{Binding IsValidForAdvancedFind, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Security Types" Binding="{Binding SecurityTypes, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Metadata Id" Binding="{Binding MetadataId, Converter={StaticResource ConvertObject}}" />
                        </data:DataGrid.Columns>
                    </data:DataGrid>
                </Grid>
            </sdk:TabItem>

            <sdk:TabItem Header="N:N Relationships">
                <Grid HorizontalAlignment="Stretch" >
                        <data:DataGrid Grid.Row="3" AutoGenerateColumns="False"  ItemsSource="{Binding FilteredRelationshipsNNList}" HorizontalAlignment="Stretch"  Name="uxManyToMany" IsReadOnly="True" >
                        <!--<data:DataGrid.ColumnHeaderStyle>
                            <Style TargetType="primitives:DataGridColumnHeader" >
                                <Setter Property="FontSize" Value="12" />
                                <Setter Property="FontWeight" Value="Bold"  />
                                <Setter Property="Margin" Value="0" />
                                <Setter Property="Padding" Value="2" />
                                <Setter Property="VerticalContentAlignment" Value="Bottom" />
                                <Setter Property="Height" Value="140" />
                                <Setter Property="ContentTemplate" >
                                    <Setter.Value>
                                        <DataTemplate >
                                            <layout:LayoutTransformer>
                                                <layout:LayoutTransformer.LayoutTransform>
                                                    <RotateTransform Angle="-35"/>
                                                </layout:LayoutTransformer.LayoutTransform>
                                                <TextBlock Text="{Binding}" TextWrapping="Wrap"   />
                                            </layout:LayoutTransformer>
                                        </DataTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </data:DataGrid.ColumnHeaderStyle>-->
                        <data:DataGrid.Columns>
                            <data:DataGridTextColumn Header="Schema Name" Binding="{Binding SchemaName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity 1 Logical Name" Binding="{Binding Entity1LogicalName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity 2 Logical Name" Binding="{Binding Entity2LogicalName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity 1 Intersect Attribute" Binding="{Binding Entity1IntersectAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity 2 Intersect Attribute" Binding="{Binding Entity2IntersectAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity 2 Associated Menu Configuration" Binding="{Binding Entity2AssociatedMenuConfiguration, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity 1 Associated Menu Configuration" Binding="{Binding Entity1AssociatedMenuConfiguration, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Custom Relationship" Binding="{Binding IsCustomRelationship, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Customizable" Binding="{Binding IsCustomizable, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Managed" Binding="{Binding IsManaged, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Advanced Find" Binding="{Binding IsAuditEnabledIsValidForAdvancedFind, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Security Types" Binding="{Binding ReferencingAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Metadata Id" Binding="{Binding ReferencingEntity, Converter={StaticResource ConvertObject}}" />
                        </data:DataGrid.Columns>
                    </data:DataGrid>
                </Grid>
            </sdk:TabItem>

            <sdk:TabItem Header="1:N Relationships">
                <Grid HorizontalAlignment="Center" >
                        <data:DataGrid Grid.Row="5" AutoGenerateColumns="False"  ItemsSource="{Binding FilteredRelationships1NList}" HorizontalAlignment="Stretch"  Name="uxOneToMany" IsReadOnly="True" >
                        <!--<data:DataGrid.ColumnHeaderStyle>
                            <Style x:Name="AngleHeader"  TargetType="primitives:DataGridColumnHeader" >
                                <Setter Property="FontSize" Value="12" />
                                <Setter Property="FontWeight" Value="Bold"  />
                                <Setter Property="Margin" Value="0" />
                                <Setter Property="Padding" Value="2" />
                                <Setter Property="VerticalContentAlignment" Value="Bottom" />
                                <Setter Property="Height" Value="140" />
                                <Setter Property="ContentTemplate" >
                                    <Setter.Value>
                                        <DataTemplate >
                                            <layout:LayoutTransformer>
                                                <layout:LayoutTransformer.LayoutTransform>
                                                    <RotateTransform Angle="-35"/>
                                                </layout:LayoutTransformer.LayoutTransform>
                                                <TextBlock Text="{Binding}" TextWrapping="Wrap"   />
                                            </layout:LayoutTransformer>
                                        </DataTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </data:DataGrid.ColumnHeaderStyle>-->
                        <data:DataGrid.Columns>
                            <data:DataGridTextColumn Header="Schema Name" Binding="{Binding SchemaName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referencing Entity" Binding="{Binding ReferencingEntity, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referenced Entity" Binding="{Binding ReferencedEntity, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referencing Attribute" Binding="{Binding ReferencingAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referenced Attribute" Binding="{Binding ReferencedAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Associated Menu Configuration" Binding="{Binding AssociatedMenuConfiguration, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Cascade Configuration" Binding="{Binding CascadeConfiguration, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Custom Relationship" Binding="{Binding IsCustomRelationship, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Customizable" Binding="{Binding IsCustomizable, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Managed" Binding="{Binding IsManaged, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Advanced Find" Binding="{Binding IsValidForAdvancedFind, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Security Types" Binding="{Binding SecurityTypes, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Metadata Id" Binding="{Binding MetadataId, Converter={StaticResource ConvertObject}}" />
                        </data:DataGrid.Columns>
                    </data:DataGrid>
                </Grid>
            </sdk:TabItem>
        </sdk:TabControl>


    </Grid>
    </toolkit:BusyIndicator>
</core:ViewBase>
